import tkinter as tk
from tkinter import messagebox
if __name__ == '__main__':
    def LoginButton():
        u = rt.username.get()
        p = rt.password.get()
        if len(u) == 0 or len(p) == 0:
            messagebox.showerror('提示:', '输入信息为空')
        else:
            messagebox.showinfo('提示:', '用户名: %s\n密码为: %s\n' % (u, p))


    # 主窗口
    rt = tk.Tk()
    rt.title('成绩发布系统')
    rt.geometry('300x300')

    # 变量
    rt.username = tk.StringVar()
    rt.password = tk.StringVar()

    # 账号
    f1 = tk.Frame(rt)
    tk.Label(f1, text='账号:  ').grid(row=0, column=0, padx=30)
    tk.Entry(f1, textvariable=rt.username).grid(row=0, column=1)
    f1.grid(pady=50)

    # 密码
    f2 = tk.Frame(rt)
    tk.Label(f2, text='密码:  ').grid(row=1, column=0, padx=30)
    tk.Entry(f2, show='*', textvariable=rt.password).grid(row=1, column=1)
    f2.grid()

    # 登录按钮
    tk.Button(rt, text='登录', command=LoginButton).grid(pady=30)
    rt.mainloop()

